﻿using System;
using System.Collections.Generic;
using System.Text;

namespace VerticalProcesses
{
    public class GRUForest:GRUClass
    {
        private CanopyType canopy;
        
        public override void Initialize(Dictionary<string, double> InitialConditions)
        {
            throw new Exception("The method or operation is not implemented.");
            //initialize(InitialConditions);
        }
        public override void Change(Dictionary<string, double> InitialConditions)
        {
            throw new Exception("The method or operation is not implemented.");
            //initialize(InitialConditions);
        }
        protected override void AccountForCanopy(DateTime timeStep, ref double gruRain, ref double gruSnow, ref double gruShortRad)
        {

            canopy.Update(timeStep, gruRain, gruSnow, gruShortRad, CurrentEvaporation, Latitude, Longitude, Elevation, TimeZone, Slope, Aspect);
            
            gruRain = canopy.ThrfRain;
            gruSnow = canopy.ThrfSnow;
            gruShortRad = canopy.ShortRadBelowCanopy;
            // Calculate evaporation that reaches the soil or snow by subtracting the evaporation of  has already
            // been lost from the canopy from the potential evaporation  
            CurrentEvaporation -= canopy.IntEvapRain - canopy.IntEvapSnow;
            ActualEvaporation += canopy.IntEvapRain + canopy.IntEvapSnow;
            Throughfall = canopy.ThrfRain + canopy.ThrfSnow;
            IntRain = canopy.IntStorageRain;
            IntSnow = canopy.IntStorageSnow;
        
        }
        
       
     public GRUForest(double timeStepHrs, string GRUID, double latitude, double longitude, double elevation, double area, double slope, double aspect, double timeZone, bool write, string metStation, string evapoEq, string snowEngergyInputEq, 
            string canopyType, string snowpackType, string soilType, Dictionary<string, double> gruGlobalParameters, Dictionary<string, double> gruLocalParameters)
         : base(timeStepHrs, GRUID, latitude, longitude, elevation, area, slope, aspect, timeZone, write, metStation, evapoEq, snowEngergyInputEq, canopyType, snowpackType, soilType, gruGlobalParameters, gruLocalParameters)
        {
            switch (canopyType.ToUpper())
            {
                case "1LAYER": canopy = new SimpleRutter(CrownClosure, timeStepHrs, gruGlobalParameters["maxsnowint"], gruGlobalParameters["maxrainint"],
                    gruGlobalParameters["crintf"],gruGlobalParameters["csintf"],gruGlobalParameters["alphac"],gruLocalParameters["dia"],gruLocalParameters["n"],
                    gruLocalParameters["hs"],gruLocalParameters["hc"]); break;
                default: throw new NotImplementedException();
            }
    
        }
    }
}
